/**
 * 按索引删除
 */
Array.prototype.remove = function(index){
	if(isNaN(index) || index > this.length){return false;}
	for(var i=0,n=0; i < this.length; i++){
		if(this[i] != this[index]){
	       this[n++] = this[i];
	    }
	 }
     this.length -= 1;
     return true;
};

/**
 * 获取指定值在数组中的索引
 */
Array.prototype.indexOf = function(value){
	var index = -1;
	for(var i = 0; i < this.length; i++){
		if(value == this[i]){
			index = i;
			break;
		}
	}
	return index;
}

/**
 * 删除指定值
 * @param value
 */
Array.prototype.removeValue = function(value){
	var index = this.indexOf(value);
	if(index != -1){
		this.remove(index);
	}
}

/**
 * 是否存在指定的值
 */
Array.prototype.isExist = function(value){
	var flag = (this.indexOf(value) != -1);
	return flag;
}

function trimstr(str) {
    return str.replace(/(^\s*)|(\s*$)/g, "");
  }
  
  function getXMLReq(){
  	if(window.XMLHttpRequest){
		req = new XMLHttpRequest();
	}else if(window.ActiveXObject){
		req = new ActiveXObject("microsoft.XMLHttp");
	}
	return req ;
  }
  

function doSaveAction(params, url, iframeObj, formObj) {
  if (params == null || url == null) {
    alert("\u4fdd\u5b58\u64cd\u4f5c\u5931\u8d25!");
    return;
  }
  formObj.action = url;
  formObj.target = iframeObj.name;
  var len = params.length;
  
  formObj.innerHTML = "";
  for (var i = 0; i < len; i++) {
    addParamToForm(formObj, params[i][0], params[i][1]);
  }
  formObj.submit();
}

function addParamToForm(formObj, itemName, itemValue) {
  inputObj.setAttribute("name", itemName);
  inputObj.setAttribute("value", itemValue);
  inputObj.setAttribute("type", "hidden");
  formObj.appendChild(inputObj);
}